﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.ComponentModel;

namespace _180FrameWork.CustControls
{
    public class CustDataGridViewCheckBoxColumn : DataGridViewColumn
    {
        /// <summary>
        /// 选中事件
        /// </summary>
        [Category("Data")]
        [Description("CustDataGridViewCheckBoxColumn_CheckBoxClick")]
        public event CheckBoxClickedHandler CheckBoxClick;

        public CustDataGridViewCheckBoxColumn()
            : base(new DataGridViewCheckBoxCell())
        {
            //建立表头单元格
            var headerCell = new CustDataGridViewCheckBoxHeaderCell();
            headerCell.OnCheckBoxClicked += new CheckBoxClickedHandler(headerCell_OnCheckBoxClicked);
            this.HeaderCell = headerCell;
            this.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
        }

        void headerCell_OnCheckBoxClicked(object sender, CustDataGridViewCheckBoxHeaderCellEventArgs e)
        {
            if (CheckBoxClick != null)
            {
                CheckBoxClick(sender, e);
            }
        }

     
    }
}
